package com.wxy;

import org.apache.http.HttpHost;
import org.elasticsearch.client.RestClient;
import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.amqp.support.converter.Jackson2JsonMessageConverter;
import org.springframework.amqp.support.converter.MessageConverter;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.transaction.annotation.EnableTransactionManagement;

/**
 * @author 47868
 * 在服务中开启rabbitmq
 * 在文件中开启ElasticSearch和Kabana服务
 */
@SpringBootApplication
@EnableTransactionManagement
public class LibSystemApplication {
    public static void main(String[] args) {
        SpringApplication.run(LibSystemApplication.class, args);
    }
    /**连接ElasticSearch*/
    @Bean
    public RestHighLevelClient client() {
        return new RestHighLevelClient(RestClient.builder(HttpHost.create("http://localhost:9200")));
    }

    /**
     * rabbitMQ消息转换器的配置
     */
    @Bean
    public MessageConverter messageConverter() {
        return new Jackson2JsonMessageConverter();
    }
}
